﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SweptVolume.CApSVTimeSampleSimulationHandler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.SweptVolume;

public class CApSVTimeSampleSimulationHandler : CApSVOrderedLocationsSimulationHandler
{
  private double m_timeInterval;

  public CApSVTimeSampleSimulationHandler(
    ITxOrderedCompoundOperation operation,
    double timeInterval)
    : base(operation)
  {
    this.m_timeInterval = timeInterval;
  }

  public CApSVTimeSampleSimulationHandler(ITxRoboticProgram roboticProgram, double timeInterval)
    : base(roboticProgram)
  {
    this.m_timeInterval = timeInterval;
  }

  public override void init()
  {
    base.init();
    this.m_simulationPlayer.TimeInterval = this.m_timeInterval;
    this.m_simulationPlayer.TimeIntervalReached += new TxSimulationPlayer_TimeIntervalReachedEventHandler(this.onTimeIntervalReached);
  }

  public override void cleanup()
  {
    base.cleanup();
    this.m_simulationPlayer.TimeIntervalReached -= new TxSimulationPlayer_TimeIntervalReachedEventHandler(this.onTimeIntervalReached);
    this.m_simulationPlayer.TimeInterval = TxApplication.Options.Motion.TimeInterval;
  }

  protected void onTimeIntervalReached(
    object sender,
    TxSimulationPlayer_TimeIntervalReachedEventArgs args)
  {
    this.triggerSamplingOccurenceReachedEvent();
  }

  protected override void onLocationReached(ITxLocationOperation locOp)
  {
    this.triggerSamplingOccurenceReachedEvent();
  }
}
